local lulue = fk.CreateSkill {

  name = "joy__lulue",

  tags = {  },

}



lulue:addEffect(fk.EventPhaseStart, {
  name = "joy__lulue",
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(lulue.name) and player.phase == Player.Play
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(room:getOtherPlayers(player), function(p)
      return (p:getHandcardNum() <= #player.player_cards[Player.Hand] and not p:isKongcheng()) end), Util.IdMapper)
    if #targets == 0 then return end
    local to = room:askForChoosePlayers(player, targets, 1, 1, "#joy__lulue-choose", lulue.name, true)
    if #to > 0 then
      event:setCostData(self, to[1])
      return true
    end
    return false
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(event:getCostData(self))
    local choice = room:askForChoice(to, {"lulue_give", "lulue_slash"}, lulue.name, "#lulue-choice:"..player.id)
    if choice == "lulue_give" then
      local dummy = Fk:cloneCard("dilu")
      dummy:addSubcards(to:getCardIds(Player.Hand))
      room:obtainCard(player, dummy, false, fk.ReasonGive)
      player:turnOver()
    else
      to:turnOver()
      room:useVirtualCard("slash", nil, to, player, lulue.name, true)
    end
  end,
})

return lulue